﻿using System.Threading.Tasks;
using Microsoft.Playwright;

namespace BrowserCollect;

/// <summary>
/// 默认采集逻辑，返回该url加载完的dom页面
/// </summary>
public class DefaultCollectScript : ICollectScript
{
    public bool IsMatch(string url) => true;

    public async Task<string> GetHtml(string url, IPage page)
    {
        await page.GotoAsync(url, new PageGotoOptions()
        {
            WaitUntil = WaitUntilState.Load,
            Timeout = 60_000,
        });
        // await page.ScreenshotAsync(new PageScreenshotOptions() { Path = "default-page.png", FullPage = true });
        return await page.ContentAsync();
    }
}